<template>
  <div align="center">
      <el-card style="width: 1000px;height: 800px" align="center">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="用户名">
            <el-input v-model="form.username" disabled></el-input>
          </el-form-item>
          <el-form-item label="真实姓名">
            <el-input v-model="form.realname"></el-input>
          </el-form-item>
          <el-form-item label="身份">
            <el-input v-model="form.usertype" disabled ></el-input>
          </el-form-item>
          <el-form-item label="手机号码">
            <el-input v-model="form.mobile"></el-input>
          </el-form-item>
          <el-form-item label="信息">
            <el-input v-model="form.notes"></el-input>
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createtime"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">修改</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
</template>
<script>
  export default {
    data() {
      return {
        form: {
          username:window.sessionStorage.getItem('username'),
          realname:'',
          usertype:'',
          mobile:'',
          notes:'',
          createtime:''
        }
      }
    },
    created(){
      this.getMlusersMessage()
    },
    methods: {
      async getMlusersMessage(){
        const {data:res}=await this.$http.get('mlusers/selectMlusers',{params:{username:this.form.username}})
        this.form.username=res.username
        this.form.realname=res.realname
        this.form.createtime=res.createtime
        this.form.mobile=res.mobile
        this.form.notes=res.notes
        if(res.usertype==1){
          this.form.usertype='管理员'
        }
        if(res.usertype==2){
          this.form.usertype='内审'
        }
        if(res.usertype==3){
          this.form.usertype='外审'
        }
        if(res.usertype==4){
          this.form.usertype='财务审核'
        }
        console.log(res.realname)
      },
      onSubmit() {
        this.$confirm('是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http.get('mlusers/editMlusers',{params:
              {username:this.form.username,
          realname:this.form.realname,
          mobile:this.form.mobile,
          notes:this.form.notes,
          createtime:this.form.createtime}})
          this.getMlusersMessage()
          this.getMlusersMessage()
          this.$message({
            type: 'success',
            message: '修改成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
      },
      open(id) {

      },
    }
  }
</script>
<style>

</style>
